<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/16
 * Time: 10:02
 */

namespace app\admin\model;


class Card extends DataBase
{
    protected $name = 'card';
    protected $autoWriteTimestamp=true;

    public function getDataList()
    {
        $where = [];
        $key = input('key');
        $value = input('value');
        if(!empty($key) && !empty($value)){
            if($key == 'status'){
                switch(trim($value)){
                    case '上架': $where[] = ['status','=','0'];break;
                    case '下架': $where[] = ['status','=','1'];break;
                    default : $where[] = [];
                }
            }else
                $where[] = [$key,'=',$value];
        }
        $order = input('sort','id').' '.input('order','asc');
        $page_config = array(
           'page' => input('get.offset',1),
            'list_rows' => input('get.limit',100)
        );
        return $this->where($where)->order($order)->paginate($page_config);
    }
}
